package com.scm.controller;


import com.scm.util.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import java.sql.SQLException;

/**
 * @ClassName ScmControllerAdvice
 * @Description TODO
 * @Author Xu
 * @Date 2021/7/20 9:37
 * @Version 1.0
 **/
@ControllerAdvice
public class ScmControllerAdvice {
    @ExceptionHandler(SQLException.class)
    @ResponseBody
    public Result doSqlException(Exception e) {
        e.printStackTrace();
        return Result.error("数据库错误");
    }

    @ExceptionHandler(Exception.class)
    @ResponseBody
    public Result doException(Exception e) {
        e.printStackTrace();
        return Result.error("服务器错误");
    }
}
